process.env.NODE_ENV = "development";

const webpack = require("webpack");
const WebpackBar = require("webpackbar");
const paths = require("./paths");
const path = require("path");
const loaders = require("./loaders");

const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
  mode: "development",
  entry: paths.appIndexJS,
  output: {
    pathinfo: true,
    filename: "static/js/[name].bundle.js",
    chunkFilename: "static/js/[name].chunk.js",
    publicPath: "/",
    globalObject: "this",
  },
  resolve: {
    modules: [paths.appNodeModules],
    extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
    alias: {
      "@/*": path.resolve(__dirname, "../src"),
    },
    plugins: [],
  },
  devtool: "eval-source-map",
  module: {
    noParse: [/moment/],
    strictExportPresence: true,
    rules: [
      {
        oneOf: [loaders.svgLoader, loaders.urlLoader, loaders.babelLoader, loaders.cssLoaderDev, loaders.scssLoaderDev, loaders.lessLoaderDev, loaders.fileLoader],
      },
    ],
  },
  optimization: {
    namedModules: true,
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: paths.appHtml,
    }),
    new webpack.HotModuleReplacementPlugin(),
    new WebpackBar(),
  ],
  node: {
    dgram: "empty",
    fs: "empty",
    net: "empty",
    tls: "empty",
    child_process: "empty",
  },
  performance: {
    hints: "warning",
  },
  stats: {
    // copied from `'minimal'`
    all: false,
    modules: true,
    maxModules: 0,
    errors: true,
    warnings: true,
    // our additional options
    moduleTrace: true,
    errorDetails: true,
  },
  target: "web",
  externals: {},
};
